#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
bool a[30],b[30];
bool L[20];
ll num[11]={0,1,0,0,2,10,4,40,92,352,724};
bool judge(ll x,ll y,ll n){
    if(a[x-y+n]||b[x+y]||L[y])return false;
    else return true;
}
ll f(ll i,ll n){
    if(i>n)return 1;
    ll ans=0;
    for(ll j=1;j<=n;j++){
        if(judge(i,j,n)){
            a[i-j+n]=true;
            b[i+j]=true;
            L[j]=true;
            ans+=f(i+1,n);
            a[i-j+n]=false;
            b[i+j]=false;
            L[j]=false;
        }
    }
    return ans;
}

int main()
{
    IOS;
    ll n;
    while(cin>>n&&n){
        cout<<num[n]<<endl;
        // memset(a,false,sizeof(a));
        // memset(b,false,sizeof(b));
        // memset(L,false,sizeof(L));
        // cout<<f(1,n)<<endl;
    }
    getchar();
    getchar();
    return 0;
}
